#! /usr/bin/python

import math
import time

tt = time.time()

limit = 120000
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a%b)

def sieve(n):
    ll = [i for i in range(n)]
    for i in range(2, int(math.sqrt(n))+1):
	for j in range(i**2, n, i):
	    ll[j] = 0
    return [p for p in ll if p != 0]

def radical(n, primes):
    ll = [i for i in range(n)]
    for i in primes:
	for j in range(i**2, n, i):
	    if (j/i)%i == 0:
		ll[j] = ll[j/i]
	    else: ll[j] = ll[i]*ll[j/i]
    return ll

primes = sieve(limit)

primes.remove(1)
rad = radical(limit, primes)
#print rad[500:1030]
#setrad = set(rad)
#print len(setrad)
#listrad = [i for i in setrad]
#listrad.sort()

ss = 0
for c in range(8, limit):
    if rad[c] >= c/2: continue
    for a in range(1, c/2):
	b = c - a
	if rad[b] == b: continue
	if gcd(rad[a], rad[b]) == 1 and rad[a]*rad[c]*rad[b] < c:
	   ss += c

print ss
print time.time() - tt
